Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuke-base-input

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-base-input

基础输入框

  • 2.3.12
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

BaseInput

  • category: Components
  • chinese: 基础输入框
  • type: 基本

API

Props

参数说明类型默认值可选值
multiple多行booleanfalse
type输入类型Stringtexttext date tel number
disabled是否禁用booleanfalse
readOnly是否只读Booleanfalse
maxLength最大长度,只有 type = text 才生效number-
onInput输入事件function(value, e)false
onFocusFocus 事件functionfalse
onBlurBlur 事件functionfalse
onChangechangefunction(value, e)
onReturn点击虚拟键盘右下角的键触发的事件,在 native 端使用原生事件,web 端使用 keyup 且 charCode = 13 代替。返回值 e {returnKeyType:'类型',value:'输入框的值'}function(e)false
returnKeyType虚拟键盘右下角的文案,目前只在 native 有效stringdefaultdefault go next search send done
rowsmultiple = true 时,可同时显示的行数number2
placeholderplaceholder 文本string-
placeholderColorplaceholder 颜色,仅 native 有效string'#999999'

实例方法

  • focus()

    让 input 获得焦点

  • blur()

    让 input 失去焦点

  • getValue()

    获取输入框的值

  • setNativeFormatRule(rules) [weex 0.17+]

    设置 native 中对实时输入内容格式化的规则,这个方法常用于前端无法解决的 native 双向绑定的场景。

    以下 demo 给出在客户端上信用卡卡号输入时,每输入 4 个数字自动加入一个空格的场景:

    const rules={
      formatRule: '/(\\d{4})(?!$)/g',
      formatReplace: '$1 ',
      recoverRule: '/(\\s*)/g',
      recoverReplace: '',
    }
    componentDidMount() {
      if (isWeb) {
        //...
      } else {
        setTimeout(() => {
          this.refs['text-field'] && this.refs['text-field'].setNativeFormatRule(rules);
        }, 500);
      }
    }
    

Keywords

FAQs

Package last updated on 26 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc